package pro.spring.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import pro.spring.inter.FanMapper;
import pro.spring.model.Fan;
import pro.spring.vo.PaginationVo;

@Service
public class FanService{

	@Autowired
	private FanMapper FanMapper;
	
	public int deleteByPrimaryKey(Integer id) {
		return FanMapper.deleteByPrimaryKey(id);
	}

	public int insert(Fan record) {
		return FanMapper.insert(record);
	}

	public Fan selectByPrimaryKey(Integer id) {
		return FanMapper.selectByPrimaryKey(id);
	}

	public int updateByPrimaryKey(Fan record) {
		return FanMapper.updateByPrimaryKey(record);
	}
	
	public PaginationVo<Fan> getPaginationInfo(int pagenum,int pagesize){
		//int pagenum是当前的页码,int pagesize是每页显示的数据数量
		PaginationVo<Fan> pageVo=new PaginationVo<Fan>();
		//一定要在setPageCount()方法之后执行setPageNum
		pageVo.setCount(FanMapper.selectCount());
		pageVo.setRows(pagesize);
		pageVo.setPageNum(pagenum);
		pageVo.setList(FanMapper.selectListPage(pageVo.getOffset(), pageVo.getRows()));
		return pageVo;
	}
}
